<template>
  <ul class="todo-list">
    <!-- completed: 完成的类名 -->
    <!-- 2.2判断是否用类 -->
    <li :class="{ completed: obj.isDone }" v-for="obj in arr" :key="obj.id">
      <div class="view">
        <!-- 2.1循环 -->
        <input class="toggle" type="checkbox" v-model="obj.isDone" />
        <label>{{ obj.name }}</label>
        <button class="destroy" @click="delFn(obj.id)"></button>
      </div>
    </li>
  </ul>
</template>

<script>
export default {
  //2.0接收传入的数组
  props: ["arr"],
  methods: {
    //4.1 子传父
    delFn(id) {
      this.$emit("del", id)
    },
  },
}
</script>
